package com.dingreading.cloud.web.service.impl;

import com.dingreading.cloud.web.dto.ReadstarGradeBookDto;
import com.dingreading.cloud.web.entity.table.ReadstarGradeTableDef;
import com.mybatisflex.core.query.QueryWrapper;
import com.dingreading.cloud.web.entity.ReadstarGrade;
import com.dingreading.cloud.web.mapper.ReadstarGradeMapper;
import com.dingreading.cloud.web.service.ReadstarGradeService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *  服务层实现。
 *
 * @author Administrator
 * @since 2025-03-24
 */
@Service
public class ReadstarGradeServiceImpl extends BaseServiceImpl<ReadstarGradeMapper, ReadstarGrade, ReadstarGradeTableDef> implements ReadstarGradeService {

    @Override
    protected ReadstarGradeTableDef getTable() {
        return ReadstarGradeTableDef.readstarGrade;
    }

    @Override
    public List<ReadstarGradeBookDto> gradeAndBookList() {
        QueryWrapper wrapper = QueryWrapper.create()
                .where(table.enabled.eq(1))
                .orderBy(table.grade.asc());
        return getMapper().selectListWithRelationsByQueryAs(wrapper, ReadstarGradeBookDto.class);
    }
}
